<!DOCTYPE html>
<html lang="zxx">
<head>
    <title>主页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="UTF-8">
    <meta name="keywords" content="主页">
    <link href="//fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/font-awesome.min.css" type="text/css" media="all">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>
<section class="w3l-hotair-form">
    <h1>主页</h1>
    <div class="container">
        <div class="workinghny-form-grid">
            <div class="main-hotair">
                <div class="content-wthree">
                    <h2>欢迎来到主页</h2>
                    <button id="logoutBtn" class="btn">退出登录</button>
                    <button id="manageMembersBtn" class="btn">成员管理</button>
                    <button id="manageGroupsBtn" class="btn">小组管理</button>
                </div>
                <div class="w3l_form align-self">
                    <div class="left_grid_info">
                        <img src="images/1.png" alt="主页图片" class="img-fluid">
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(document).ready(function() {
        $('#logoutBtn').on('click', function(event) {
            event.preventDefault();

            $.ajax({
                url: 'http://localhost:8080/Servlet/logout',
                method: 'POST',
                xhrFields: {
                    withCredentials: true  // 允许发送凭据
                },
                success: function() {
                    alert('退出登录成功');
                    window.location.href = 'http://localhost:8080/Servlet/Log_HTML/log.html'; // 跳转到登录页面
                },
                error: function() {
                    alert('退出登录失败，请重试');
                }
            });
        });

        $('#manageMembersBtn').on('click', function() {
            window.location.href = 'http://localhost:8080/Servlet/Log_HTML/numbers_management.html'; // 跳转到成员管理页面
        });

        $('#manageGroupsBtn').on('click', function() {
            window.location.href = 'http://localhost:8080/Servlet/Log_HTML/group_management.html'; // 跳转到小组管理页面
        });
    });
</script>
</body>
</html>
